package com.kgc.sbt.service.impl;

import com.alibaba.dubbo.config.annotation.Reference;
import com.kgc.sbt.api.OrderApi;
import com.kgc.sbt.beans.*;
import com.kgc.sbt.service.OrderService;
import com.kgc.sbt.utils.KdApiSearchUtil;
import com.kgc.sbt.utils.PageSupport;
import com.sun.corba.se.spi.servicecontext.UEInfoServiceContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created on 2021/8/17.
 * <p>
 * Author: wuqilong
 * <p>
 * Description: 订单业务实现类
 */
@Service
@Slf4j
public class OrderServiceImpl implements OrderService {

    @Reference
    private OrderApi orderApi;

    @Override
    public Integer selectIdByToken(String token) {
        return orderApi.selectUserIdByToken(token);
    }

    @Override
    public List<Cart> queryCartInfo(Integer userId) {
        return orderApi.getCartInfo(userId);
    }

    @Override
    public Address queryAddressInfo(Integer userId) {
        return orderApi.getAddressInfo(userId);
    }

    @Override
    public List<UserCoupons> queryCouponsInfo(Integer userId) {
        return orderApi.getCouponsInfo(userId);
    }

    @Override
    public int queryVipInfo(Integer userId) {
        return orderApi.getVipInfo(userId);
    }

    @Override
    public boolean insertOrderMain(OrderMain orderMain) {
        return orderApi.putOrderMain(orderMain);
    }

    @Override
    public boolean insertOrderDetail(OrderDetail orderDetail) {
        return orderApi.putOrderDetail(orderDetail);
    }

    @Override
    public Product queryProductById(Integer productId) {
        return orderApi.getProductById(productId);
    }

    @Override
    public boolean updateUserPoints(Integer userId, Integer integral) {
        return orderApi.updUserPoints(userId, integral);
    }

    @Override
    public boolean updateProductStock(Integer productId, Integer quantity) {
        return orderApi.updProductStock(productId, quantity);
    }

    @Override
    public PageSupport<OrderMain<OrderDetail>> queryOrderByStatus(Integer userId, Integer orderStatus, Integer currPageNo, Integer pageSize) {
        return orderApi.getOrderByStatus(userId, orderStatus, currPageNo, pageSize);
    }

    @Override
    public OrderMain queryStatusByOrderNum(String orderNum) {
        return orderApi.getStatusByOrderNum(orderNum);
    }

    @Override
    public String queryLogisticsInfo(String logisticCode) {
        return KdApiSearchUtil.queryInfo(logisticCode);
    }

    @Override
    public Stock queryStockById(Integer productId) {
        return orderApi.getStockById(productId);
    }

    @Override
    public boolean insertArrivalReminder(Integer userId, Integer productId, String userPhone) {
        return orderApi.putArrivalReminder(userId, productId, userPhone);
    }

    @Override
    public List<ArrivalReminder> queryAllArrivalReminder() {
        return orderApi.getAllArrivalReminder();
    }

    @Override
    public boolean deleteArrivalReminder(Integer reminderId) {
        return orderApi.delArrivalReminder(reminderId);
    }

    @Override
    public List<Stock> queryAllStock() {
        return orderApi.getAllStock();
    }

    @Override
    public boolean updateStock(Integer productId, Integer count) {
        return orderApi.updStock(productId, count);
    }

    @Override
    public boolean deleteCoupons(Integer couponsId) {
        return orderApi.delCoupons(couponsId);
    }

    @Override
    public List<UserCoupons> queryCoupons(Integer userId, String couponsNum) {
        return orderApi.getCoupons(userId, couponsNum);
    }

    @Override
    public boolean deleteCartProduct(Integer userId) {
        return orderApi.delCartProduct(userId);
    }
}
